<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" href="css/style.css">

    <style media="print">
        @page {

        }
    </style>
    <script src="/jquery-3.6.0.min.js"></script>
    <script src="/dist_JsBarcode.all.min.js"></script>
    <script src="./echarts.js"></script>
</head>
<body >
<!--startprint-->
    <div style="-webkit-print-color-adjust: exact;">
    <h1 style="text-align: center">
        山东大学附属儿童医院(济南市儿童医院)视觉健康档案
    </h1>
    <div class="comtent box">
        <table  border="1" cellspacing="0" width="1000" align="center">
            <tr>
                <td>
                    <div class="header">
                        <p>
                            学校:<a id="schname"></a>
                        </p>
                        <p>
                            年级:<a id="gradename"></a>
                        </p>
                        <p>
                            班级:<a id="classname"></a>
                        </p>
                        <p>
                            检查编号:<a id="classId"></a>
                        </p>
                        <p>
                            姓名:<a id="name"></a>
                        </p>
                        <p>
                        性别:<a id="sex"></a>
                    </p>
                        <p>
                            年龄:<a id="age"></a>
                        </p>
                        <p>
                            检查时间:<a id="reporttime"></a>
                        </p>
                    </div>

                </td>
            </tr>
            <tr>
                <td>
                    <div class="result">
                        <h4>
                            本次检查结果
                        </h4>
                        <table border="1" cellspacing="0" width="960">
                            <tr>
                                <td rowspan="2" bgcolor="#D9D9D9">

                                        眼别

                                  </td>
                                <td rowspan="2" bgcolor="#D9D9D9">裸眼视力</td>
                                <td rowspan="2" bgcolor="#D9D9D9">戴镜视力</td>
                                <td colspan="3" bgcolor="#D9D9D9" height="30">电脑验光结果</td>

                            </tr>
                            <tr>

                                <td   bgcolor="#D9D9D9">
                                    球镜
                                </td>
                                <td bgcolor="#D9D9D9" height="30">
                                    柱镜
                                </td>
                                <td bgcolor="#D9D9D9">
                                    轴位
                                </td>
                            </tr>
                            <tr>
                                <td bgcolor="#D9D9D9" height="30">
                                    右眼
                                </td>
                                <td>
                                    <span id="eyerightdata"></span>
                                </td>
                                <td>
                                    <span id="eyerightclassdata"></span>
                                </td>
                                <td>
                                    <span id="yanguangyouqiujing"></span>
                                </td>
                                <td>
                                    <span id="yanguangyouzhujing"></span>
                                </td>
                                <td>
                                    <span id="yanguangyouzhouwei"></span>
                                </td>
                            </tr>
                            <tr>
                                <td bgcolor="#D9D9D9" height="30">
                                    左眼
                                </td>
                                <td>
                                    <span id="eyeleftdata"></span>
                                </td>
                                <td>
                                    <span id="eyeleftclassdata"></span>
                                </td>
                                <td>
                                    <span id="yanguangzuoqiujing"></span>
                                </td>
                                <td>
                                    <span id="yanguangzuozhujing"></span>
                                </td>
                                <td>
                                    <span id="yanguangzuozhouwei"></span>
                                </td>
                            </tr>
                        </table>
                    </div>

                </td>
            </tr>
        </table>
    </div>
    <div class="content">
        <table border="1" cellspacing="0" width="1000" align="center">
            <tr>
                <td height="30" style="text-align: center">
                    <h4>
                        历次视力变化趋势图
                    </h4>
                </td>
                <td height="30" style="text-align: center">
                    <h4>
                        历次屈光度变化趋势图
                    </h4>
                </td>

            </tr>
            <tr>
                <td>
                    <div class="qushicon">
                        <div class="tu" id="left1">
                            <img src="images/tu.png">
                        </div>
                        <div class="tu" id="right1">
                            <img src="images/tu.png">
                        </div>
                    </div>
                </td>
                <td>
                    <div class="qushicon">
                        <div class="tu" id="left2">
                            <img src="images/tu.png">
                        </div>
                        <div class="tu" id="right2">
                            <img src="images/tu.png">
                        </div>
                    </div>
                </td>
            </tr>
        </table>

    </div>
    <div class="shuoming comtent">
        <table border="0" cellspacing="0" width="1000" >
            <tr>
                <td width="50">
                    说明:
                </td>
                <td>
                    ①裸眼视力正常值和戴镜视力正常值一般为:3岁≥4.7，4-5岁≥4.8，6岁以上≥4.9。<br>
                    ②电脑验光中，“球镜’为近视或远视度数、“柱镜’为散光度数、“轴位’为散光的方向。<br>
                    ③因筛查现场检查项目有限，且受环境、光线、学生紧张心理等因素的影响，预警结果仅作为参考，不作为最终诊断。如需确诊，请到正规医疗机构做进一步检查。

                </td>
            </tr>
        </table>

        </div>
    <div class="jieshao comtent" >
        <table border="1" cellspacing="0" width="1000">
            <tr>
                <td height="30">
                    <h4>
                        右眼初步建议与预警提示:
                    </h4>
                </td>
            </tr>
            <tr>

                <td>
                    口1、视力目前正常，建议每3个月进行一次视力检查<br>
                    口2、目前视力正常，但是有远视储备不足和发生近视的可能性，建议到正规医院进行详细眼科检查<br>

                    口3、视力下降，建议到正规医院进行详细眼科检查，查明原因<br>

                    口4、戴镜视力正常，建议每3个月进行一次医学验光检查<br>

                    口5、戴镜视力下降，建议2周内到正规医院进行医学验光检查，更换眼镜，筛查结果不具有诊断意义，应到具备有效的医疗机构执业许可证
                    的医疗机构进一步检查以确诊。
                </td>


            </tr>
            <tr>
                <td height="30">
                    <h4>
                        左眼初步建议与预警提示:
                    </h4>
                </td>
            </tr>
            <tr>
                <td>
                    口1、视力目前正常，建议每3个月进行一次视力检查<br>
                    口2、目前视力正常，但是有远视储备不足和发生近视的可能性，建议到正规医院进行详细眼科检查<br>
                    口 3、视力下降，建议到正规医院进行详细眼科检查，查明原因<br>
                    口4、戴镜视力正常，建议每3个月进行一次医学验光检查<br>
                    口5、戴镜视力下降，建议2周内到正规医院进行医学验光检查，更换眼镜，筛查结果不具有诊断意义，应到具备有效的医疗机构执业许可证的医疗机构进一步检查以确诊。
                </td>
            </tr>
        </table>
        <div style="margin-top: 10px;font-weight: bold">
            山东大学附属儿童医院（济南市儿童医院）&nbsp;&nbsp;&nbsp;&nbsp;地址：济南市槐荫区经十路23976号 &nbsp;&nbsp;&nbsp;&nbsp;  电话：0531-59616076
        </div>
    </div>

    <div class="footer comtent" style="display: none">
        <div class="ewm">
            <table>
                <tr>
                    <td width="10">
                        扫码查询
                    </td>
                    <td>
                        <div class="ewm">
                            <img src="images/ewm.png" width="100">
                        </div>
                    </td>
                    <td width="10">
                        电子档案
                    </td>
                </tr>
            </table>
        </div>
        <div class="footerL" style="display: none">
            山东大学附属儿童医院<br>
            地址:山东大学附属儿童医院眼科(门诊二楼)<br>
            电话:0533-8526153
        </div>

    </div>
    </div>
    <!--endprint-->
    <div style="margin-top: 50px;text-align: center;">
        <div style="width: 150px;margin-left: 45%;">
            <p class="baogaobtn"  onclick='print_page()'>打印</p>
        </div>
    </div>

</body>
<script>
    var echartsWarp1= document.getElementById('left1');
    var echartsWarp2= document.getElementById('right1');
    var echartsWarp3= document.getElementById('left2');
     var echartsWarp4= document.getElementById('right2');
    var resizeWorldMapContainer = function () {//用于使chart自适应高度和宽度,通过窗体高宽计算容器高宽
        echartsWarp1.style.width = '100px';
        echartsWarp1.style.height = '100px';
        echartsWarp2.style.width = '220px';
        echartsWarp2.style.height = '210px';
        echartsWarp3.style.width = '220px';
        echartsWarp3.style.height = '210px';
         echartsWarp4.style.width = '220px';
         echartsWarp4.style.height = '210px';
    };
    var myChart1 = echarts.init(echartsWarp1)
    var myChart2 = echarts.init(echartsWarp2)
    var myChart3 = echarts.init(echartsWarp3)
     var myChart4 = echarts.init(echartsWarp4)
$(function () {
    var eyeStudentRecord = localStorage.getItem("eyeStudentRecord");
    var eyeStudent = localStorage.getItem("eyeStudent");
    var remap = localStorage.getItem("remap");
    var eyeStudentRecordInfo = JSON.parse(eyeStudentRecord);
    var eyeStudentInfo = JSON.parse(eyeStudent);
    var remapInfo = JSON.parse(remap);
    // eyeStudentInfo=undefined;
    // eyeStudentRecordInfo = undefined
    // remapInfo = undefined
    console.log(remapInfo)
    $("#schname").html(eyeStudentInfo.schname);
    $("#gradename").html(eyeStudentInfo.className.split("/")[0]);
    $("#classname").html(eyeStudentInfo.className.split("/")[1]);
    $("#name").html(eyeStudentInfo.name);
    $("#age").html(eyeStudentRecordInfo.age+"岁");
    $("#sex").html(eyeStudentInfo.sex=='1'?"男":"女");
    $("#reporttime").html(eyeStudentRecordInfo.createTime.substring(0,10));

    $("#eyeleftclassdata").html(eyeStudentRecordInfo.eyeLeftClassData);
    $("#eyeleftdata").html(eyeStudentRecordInfo.eyeLeftData);
    $("#eyerightdata").html(eyeStudentRecordInfo.eyeRightData);
    $("#eyerightclassdata").html(eyeStudentRecordInfo.eyeRightClassData);
    $("#yanguangyouqiujing").html(eyeStudentRecordInfo.yanguangYouQiuJing);
    $("#yanguangyouzhouwei").html(eyeStudentRecordInfo.yanguangYouZhouWei);
    $("#yanguangyouzhujing").html(eyeStudentRecordInfo.yanguangYouZhuJing);
    $("#yanguangzuozhouwei").html(eyeStudentRecordInfo.yanguangZuoZhouWei);
    $("#yanguangzuozhujing").html(eyeStudentRecordInfo.yanguangZuoZhuJing);
    $("#yanguangzuoqiujing").html(eyeStudentRecordInfo.yanguangZuoQiuJing);

    var rmin = Math.min(...remapInfo.rightdatas);
    var rmax = Math.max(...remapInfo.rightdatas);
    var lmin =  Math.min(...remapInfo.leftdatas)
    var lmax = Math.max(...remapInfo.leftdatas)
    // var rcs = rmax - rmin
    // var lcs = lmax - lmin
    var ljs = 0.2;
    var rjs = 0.2
    // if(rcs>lcs){
    //         ljs = (rcs - lcs)/2+0.1
    // }else if(rcs<lcs){
    //     rjs = (lcs-rcs)/2+0.1
    // }
    // console.log(rmin,rjs)
    // console.log(lmin,ljs)
    var emin = rmin>lmin?lmin:rmin
    var emax = rmax>lmax?rmax:lmax
    var itev = 0.1
    if(emax-emin>1){
        itev = Math.ceil(emax-emin)/10
    }
    const option1 = {
        title: {
            text: '右眼视力',
            textStyle: {
                fontWeight: 'normal',
                //字体系列
                fontFamily: 'sans-serif',
                fontSize:15
            }
        },
        grid: {
            top: '17%',
            left: '15%',
            right: '12%',
            bottom: '25%'
        },
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'line',
                lineStyle: {
                    color: '#3399FF',
                    type: 'solid'
                }
            },
            backgroundColor: 'rgba(66, 161, 255, 0.9)',
            borderWidth: 0,
            textStyle: {
                color: '#ffffff'
            }
        },
        xAxis: {
            data: remapInfo.dates,
            axisLabel: {
                rotate: 40
            }
        },
        yAxis: {
            type: 'value',
            min:emin-rjs,
            max:emax+rjs,
            interval:itev,
            axisLabel: {
                formatter: function (value) {
                    if (value <= (emin-rjs)) {
                        return "0"
                    }else{
                        return value.toFixed(1)
                    }
                }
            }
        },
        series: [
            {
                name: '右眼视力',
                type: 'line',
                data: remapInfo.rightdatas,
                symbol: 'circle',
                itemStyle: { // 拐点样式
                    normal: {
                        borderColor:'red',
                        borderWidth: 3
                    }
                },
            }
        ]
    }
    myChart1.setOption(option1)
    const option2 = {
        title: {
            text: '左眼视力',
            textStyle: {
                fontWeight: 'normal',
                //字体系列
                fontFamily: 'sans-serif',
                fontSize:15
            }
        },
        grid: {
            top: '17%',
            left: '15%',
            right: '12%',
            bottom: '25%'
        },
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'line',
                lineStyle: {
                    color: '#3399FF',
                    type: 'solid'
                }
            },
            backgroundColor: 'rgba(66, 161, 255, 0.9)',
            borderWidth: 0,
            textStyle: {
                color: '#ffffff'
            }
        },
        xAxis: {
            data: remapInfo.dates,
            axisLabel: {
                rotate: 40
            }
        },
        yAxis: {
            type: 'value',
            min:emin-ljs,
            max:emax+ljs,
            interval:itev,
            axisLabel: {
                formatter: function (value) {
                    if (value <= (emin-ljs)) {
                        return "0"
                    }else{
                        return value.toFixed(1)
                    }
                }
            }
        },
        series: [
            {
                name: '左眼视力',
                type: 'line',
                data: remapInfo.leftdatas,
                symbol: 'circle',
                itemStyle: { // 拐点样式
                    normal: {
                        borderColor:'red',
                        borderWidth: 3
                    }
                },
            }
        ]
    }
    myChart2.setOption(option2)
    var min1 = Math.min(...remapInfo.rightqgddatas)>0?-0.5:Math.floor(Math.min(...remapInfo.rightqgddatas));
    var max1 = Math.max(...remapInfo.rightqgddatas)<0?0.5:Math.ceil(Math.max(...remapInfo.rightqgddatas));
    var min2 =  Math.min(...remapInfo.leftqgddatas)>0?-0.5:Math.floor(Math.min(...remapInfo.leftqgddatas))
    var max2 = Math.max(...remapInfo.leftqgddatas)<0?0.5:Math.ceil(Math.max(...remapInfo.leftqgddatas));
    if(max2>max1){
        max1 = max2;
    }
    if(min1>min2){
        min1 = min2;
    }
    const option3 = {
        title: {
            text: '右眼屈光度',
            textStyle: {
                fontWeight: 'normal',
                //字体系列
                fontFamily: 'sans-serif',
                fontSize:15
            }
        },
        grid: {
            top: '17%',
            left: '30%',
            right: '12%',
            bottom: '25%'
        },
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'line',
                lineStyle: {
                    color: '#3399FF',
                    type: 'solid'
                }
            },
            backgroundColor: 'rgba(66, 161, 255, 0.9)',
            borderWidth: 0,
            textStyle: {
                color: '#ffffff'
            }
        },
        xAxis: {
            data: remapInfo.dates,
            axisLabel: {
                rotate: 40
            }
        },
        yAxis: {
            type: 'value',
            inverse: true,
            min:min1,
            max:max1,
            interval: 0.5,
            axisLabel: {
                formatter: function (value) {
                    if (value < 0) {
                        return "近视" + value.toFixed(2)
                    } else if (value > 0) {
                        return "远视+" + value.toFixed(2)
                    }else{
                        return value.toFixed(2)
                    }
                }
            }
        },
        series: [
            {
                name: '右眼屈光度',
                type: 'line',
                data: remapInfo.rightqgddatas,
                symbol: 'circle',
                itemStyle: { // 拐点样式
                    normal: {
                        borderColor:'red',
                        borderWidth: 3
                    }
                },
            }
        ]
    }
    myChart3.setOption(option3)
    const option4 = {
        title: {
            text: '左眼屈光度',
            textStyle: {
                fontWeight: 'normal',
                //字体系列
                fontFamily: 'sans-serif',
                fontSize:15
            }
        },
        grid: {
            top: '17%',
            left: '30%',
            right: '12%',
            bottom: '25%'
        },
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'line',
                lineStyle: {
                    color: '#3399FF',
                    type: 'solid'
                }
            },
            backgroundColor: 'rgba(66, 161, 255, 0.9)',
            borderWidth: 0,
            textStyle: {
                color: '#ffffff'
            }
        },
        xAxis: {
            data: remapInfo.dates,
            axisLabel: {
                rotate: 40
            }
        },
        yAxis: {
            type: 'value',
            inverse: true,
            min:min1,
            max:max1,
            interval: 0.5,
            axisLabel: {
                formatter: function (value) {
                    if (value < 0) {
                        return "近视" + value.toFixed(2)
                    } else if (value > 0) {
                        return "远视+" + value.toFixed(2)
                    }else{
                        return value.toFixed(2)
                    }
                }
            }
        },
        series: [
            {
                name: '左眼屈光度',
                type: 'line',
                data: remapInfo.leftqgddatas,
                symbol: 'circle',
                itemStyle: { // 拐点样式
                    normal: {
                        borderColor:'red',
                        borderWidth: 3
                    }
                },
            }
        ]
    }
    myChart4.setOption(option4)
})
    function callParentMethod() {
        if (window.parent && window.parent.callFromIframe) {
            window.parent.callFromIframe();
        } else {
            console.error('Parent method is not accessible');
        }
    }
    function print_page() {
        callParentMethod();
        const src1 = (myChart1).getDataURL({
            pixelRatio: 2,
            backgroundColor: '#fff',
        });
        $("#left1").html("<img src='"+src1+"' style='height: 200px;'>");
        const src2 = (myChart2).getDataURL({
            pixelRatio: 2,
            backgroundColor: '#fff',
        });
        $("#right1").html("<img src='"+src2+"' style='height: 200px;'>");
        const src3 = (myChart3).getDataURL({
            pixelRatio: 2,
            backgroundColor: '#fff',
        });
        $("#left2").html("<img src='"+src3+"' style='height: 200px;'>");
        const src4 = (myChart4).getDataURL({
            pixelRatio: 2,
            backgroundColor: '#fff',
        });
        $("#right2").html("<img src='"+src4+"' style='height: 200px;'>");
        setTimeout("print_pages()",100);
    }
    function print_pages() {
        if (!!window.ActiveXObject || "ActiveXObject" in window) { //是否ie
            remove_ie_header_and_footer();
        }
        bdhtml = window.document.body.innerHTML;
        var oldstr = document.body.innerHTML;

        sprnstr = "<!--startprint-->";
        eprnstr = "<!--endprint-->";
        prnhtml = bdhtml.substr(bdhtml.indexOf(sprnstr) + 17);
        prnhtml = prnhtml.substring(0, prnhtml.indexOf(eprnstr));
        window.document.body.innerHTML = prnhtml;
        window.print();
        document.body.innerHTML = oldstr;
    }

    function remove_ie_header_and_footer() {
        var hkey_path;
        hkey_path = "HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";
        try {
            var RegWsh = new ActiveXObject("WScript.Shell");
            RegWsh.RegWrite(hkey_path + "header", "");
            RegWsh.RegWrite(hkey_path + "footer", "");
        } catch (e) {
        }
    }
    function onbeforeprint()  {

        document.getElementsByTagName("header")[0].style.display = "none";

        document.getElementsByTagName("footer")[0].style.display = "none";

    }

    function onafterprint() {

        document.getElementsByTagName("header")[0].style.display = "block";

        document.getElementsByTagName("footer")[0].style.display = "block";

    }
</script>
</html>
